<!--
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2020-10-20 16:18:30
 * @LastEditors: sueRimn
 * @LastEditTime: 2020-11-20 16:13:18
-->
<template>
    <div class="mainBox">
        <el-page-header @back="goBack" content="选择班级" class="pageHeader">
        </el-page-header>
        <template v-if="dataList.length == 0">
            <tips :tipsText="'您还未加入班级'"></tips>
        </template>
        <template v-else>
            <div class="searchClassBox">
                <div
                    class="searchClassItemBox"
                    v-for="(el, index) in dataList"
                    :key="index"
                    @click="toClassTest(el.groupid)"
                >
                    <div class="itemBoxHeader">{{ el.group_name }}</div>
                    <hr />
                    <div class="itemBoxBody">
                        <div class="imgBox">
                            <img src="@/assets/images/icon/classList.png" />
                        </div>
                        <div class="itemBoxBodyContent">
                            <div class="teacher">
                                班主任：{{
                                    el.nicheng ? el.nicheng : "未设置昵称"
                                }}
                            </div>
                            <div>学生：{{ el.count_num }}人</div>
                        </div>
                    </div>
                </div>
            </div>
        </template>
    </div>
</template>

<script>
import { getGradeList } from "@/api/test/index";
import tips from "@/components/tips/index";
export default {
    data() {
        return {
            dataList: []
        };
    },
    components: {
        tips
    },
    filters: {},
    created() {
        this.getDataList();
    },
    methods: {
        goBack() {
            this.$router.go(-1);
        },
        // 获取班级列表
        getDataList() {
            getGradeList({}).then(res => {
                if (res.code === 200) {
                    this.dataList = res.data;
                }
            });
        },
        // 前往班级测验
        toClassTest(groupid) {
            this.$router.push({
                path: "/test/classTest/index",
                query: {
                    groupid: groupid,
                    type: 0
                }
            });
        }
    }
};
</script>

<style scoped lang="scss">
.mainBox {
    width: 100%;
    padding: 26px;
    box-sizing: border-box;

    .pageHeader {
        font-weight: bold;
        font-size: 20px;
        color: #2d3440;
    }

    .selectSearchBox {
        width: 100%;
        background-color: #ffffff;
        height: 50px;
        border-radius: 8px;
        margin-top: 20px;
        display: flex;
        align-items: center;
        padding: 5px 20px;
        box-sizing: border-box;
    }
}

.searchClassBox {
    width: 100%;
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;

    .searchClassItemBox {
        width: 32%;
        background-color: #ffffff;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
        margin: 7.6px;
        padding-bottom: 15px;
        cursor: pointer;
        .itemBoxHeader {
            height: 20px;
            line-height: 20px;
            color: #2d3440;
            font-size: 15px;
            margin: 10px 15px 0 15px;
        }

        .itemBoxBody {
            display: flex;
            padding: 10px 20px;
            box-sizing: border-box;
            .imgBox {
                background: #018854;
                border-radius: 50%;
                width: 55px;
                height: 55px;
                display: flex;
                justify-content: center;
                align-items: center;
                img {
                    width: 40px;
                    height: 40px;
                }
            }

            .itemBoxBodyContent {
                margin-left: 20px;
                color: #333;
                font-size: 14px;

                .teacher {
                    font-size: 15px;
                    color: rgba(0, 0, 0, 0.85);
                    font-weight: 600;
                }

                div {
                    margin-bottom: 8px;
                }
            }
        }

        .itemBoxBottom {
            width: 100%;
            height: 40px;
            line-height: 40px;
            position: absolute;
            bottom: 0;
            left: 0;
            border-top: #dadfe6 1px solid;
            background: #f5fcff;
            font-size: 15px;
            font-weight: 600;
            color: #018854;
            text-align: center;
            cursor: pointer;
        }
        .isActive {
            background: rgb(250, 181, 181);
            color: #ffffff;
        }
        .isJion {
            background: #018854;
            color: #ffffff;
        }
    }
}
.paginationBox {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    background-color: #ffffff;
    text-align: center;
    margin-top: 20px;
    border-radius: 8px;
}
</style>
